-- weapon module
-- By Rafael M. Savelli - september, 2nd 2009.

--local ag, st

-- weapon class.
Weapon = {
	-- attributes
	name = "faca",
	defL = 0,
	defM = -3,
	defP = -6,
	percent100 = 1,
	percent75 = 1,
	percent50 = 0,
	percent25 = 0	
}

function Weapon:new(name, defL, defM, defP, perc100, perc75, perc50, perc25, agility, strenght )
	o = nil or {}
	setmetatable(o, self)
	self.__index = self
  
	if( name ~= nil ) then
		if( agility == nil and strenght == nil ) then
			agility = 0
			strenght = 0
		end		
	end
	
	self.name = name
	self.defL = defL + agility
	self.defM = defM + agility
	self.defP = defP + agility
	self.percent100 = perc100 + strenght
	self.percent75 = perc75 + strenght
	self.percent50 = perc50 + strenght
	self.percent25 = perc25 + strenght
	
	return o	
end

function Weapon:get_name()
	return self.name
end
	-- weapon class methods.
function Weapon:set_defs( agility )
		self.defL = self.defL + agility
		self.defM = self.defM + agility
		self.defP = self.defP + agility
end

function Weapon:set_damages( strenght )
		self.percent100 = self.percent100 + strenght
		self.percent75 = self.percent75 + strenght
		self.percent50 = self.percent50 + strenght
		self.percent25 = self.percent25 + strenght
end

function Weapon:getDefL()
		return self.defL
end

function Weapon:getDefM()
		return self.defM
end

function Weapon:getDefP()
		return self.DefP
end

function Weapon:getDamage( perc )
		if( perc == 1 ) then
			return self.percent100
		end
		if( perc == 0.75 ) then
			return self.percent75
		end
		if( perc == 0.5 ) then
			return self.percent50
		end
		if( perc == 0.25 ) then
			return self.percent25
		else
			return 0
		end
end